Returns the absolute value of a numeric expression.
数値表式の絶対値を返します。
Abs (Number)
Abs (Number)
Double
倍精度
Number: Any numeric expression that you want to return the absolute value for. Positive numbers, including 0, are returned unchanged, whereas negative numbers are converted to positive numbers.
Number: 絶対値を求める数値表式。ゼロを含めた正の値については、そのままの数値が返され、負の値については、正の値への変換値が返されます。
The following example uses the Abs function to calculate the difference between two values. It does not matter which value you enter first.
下記の例は、Abs 関数を用いて 2 つの数値の差を求めています。どちらの値を先に入力しても、同じ結果が得られます。
Sub ExampleDifference
Sub ExampleDifference
Dim siW1 As Single
Dim siW1 As Single
Dim siW2 As Single
Dim siW2 As Single
siW1 = Int(InputBox$ ("Please enter the first amount","Value input"))
siW1 = Int(InputBox$ ("Please enter the first amount","Value input"))
siW2 = Int(InputBox$ ("Please enter the second amount","Value input"))
siW2 = Int(InputBox$ ("Please enter the second amount","Value input"))
Print "The difference is "; Abs(siW1 - siW2)
Print "The difference is "; Abs(siW1 - siW2)
End Sub
End Sub